<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="108px">
      <el-form-item label="检查时间" prop="checkTime">
        <el-date-picker clearable
                        v-model="queryParams.checkTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择检查时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="检查人" prop="checkByName">
        <el-input
          v-model="queryParams.checkByName"
          placeholder="请输入检查人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="reportInfoList">
      <el-table-column label="检查人" align="center" prop="nickName"/>
      <el-table-column label="所属管辖大队" align="center" prop="deptName"/>
      <el-table-column label="施工检查次数" align="center" prop="checkCount">
        <template slot-scope="scope">
          <router-link :to="{path:'/projectCheck/checkRecord',query:{checkByName:scope.row.nickName}}" class="link-type">
            <span>{{ scope.row.checkCount }}</span>
          </router-link>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


  </div>
</template>

<script>
  import { selectCheckCountTotal } from "@/api/statistics/reportForms";
  import { deptUserTreeSelect } from "@/api/system/user";
  import Treeselect from "@riophae/vue-treeselect";
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";

  export default {
    name: "reportInfo",
    components: { Treeselect },
    dicts: ['business_cons_direction_type', 'business_cons_type'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 报备信息表格数据
        reportInfoList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        //  是否显示审核弹出层
        completeOpen: false,
        //  是否显示详情弹出层
        viewOpen: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          checkTime: null,
          checkByName: null,
        },
        // 表单参数
        form: {},
      };
    },
    created() {
      this.getList();
      this.getDeptTree();
    },
    methods: {
      /** 查询报备信息列表 */
      getList() {
        this.loading = true;
        selectCheckCountTotal(this.queryParams).then(response => {
          this.reportInfoList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },

      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },

      /** 导出按钮操作 */
      handleExport() {
        this.download('statistics/reportForms/exportCheckCountTotal', {
          ...this.queryParams
        }, `checkCountTotal_${new Date().getTime()}.xlsx`)
      },

      /** 查询部门下拉树结构 */
      getDeptTree() {
        deptUserTreeSelect().then(response => {
          this.deptOptions = response.data;
        });
      },
    },

  };
</script>
